// src/main.js
import { createApp } from 'vue';
import App from './App.vue';
import router from './router'; // 引入路由配置文件
import ElementPlus from 'element-plus';
import 'element-plus/dist/index.css'; // 引入 Element Plus 的样式
// ajax
import axios from 'axios';

// 如果您正在使用CDN引入，请删除下面一行。
import * as ElementPlusIconsVue from '@element-plus/icons-vue'

const app = createApp(App)
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}
// const app = createApp(App);
// 定义全局变量
// app.config.globalProperties.WEB_DIR = 'http://localhost:80/';

const axiosInstance = axios.create({
    baseURL: 'http://localhost:80',
    timeout: 10000
});

window.addEventListener('beforeunload', () => {
    localStorage.removeItem('isAuthenticated');
    localStorage.removeItem('isManagementAuthenticated');
});

// 将 axios 实例添加到全局属性
app.config.globalProperties.$axios = axiosInstance;

app.use(router); // 使用路由
app.use(ElementPlus);

app.mount('#app');